//
//  MainLeftTVPresenter.swift
//  NewDelivery
//
//  Created by 天下宅 on 2016/11/7.
//  Copyright © 2016年 天下宅. All rights reserved.
//

import UIKit

class MainLeftTVPresenter: BaseTVPresenter {
    
    override func setupTableView() {
        self.contents = ["待接订单","我的订单","已完成订单","配送费统计","设置"]
        super.setupTableView()
    }
    
    
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 5
    }
    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        var cell = tableView.dequeueReusableCell(withIdentifier: "cell")
        if cell == nil
        {
            cell = UITableViewCell.init(style: .default, reuseIdentifier: "cell")
            cell?.accessoryType = .disclosureIndicator
            cell?.textLabel?.textColor = UIColor.white
            cell?.backgroundColor = UIColor.clear
            cell?.addLine(WithColor: UIColor.black, model: [.bottom])
            cell?.textLabel?.font = UIFont.systemFont(ofSize: 18)
            cell?.selectionStyle = .none

        }
        cell?.textLabel?.text = self.contents![indexPath.row] as? String;
        return cell!
    }
    
    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        print(self.contents![indexPath.row])
        
        
        if indexPath.row == 4
        {
            let vc = SettingVC()
            self.vc.present(vc, animated: true, completion: nil)
        }
        else if indexPath.row == 3
        {
            //配送费统计页面
            let vc = IncomeVC()
            self.vc.present(vc, animated: true, completion: nil)
        }
        else
        {
            let VC = self.vc as! MainVC

            switch indexPath.row {
            case 0:
                VC.centerTVPresenter!.orderState = .new
            case 1:
                VC.centerTVPresenter!.orderState = .my
            case 2:
                VC.centerTVPresenter!.orderState = .finish
            default:
                break;
            }
            
            
        }
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 60
    }
}
